function page() {
    var event = event || window.event;
    var pageNum = document.getElementsByName('pageNum')[0].value;
    if(!(/(^[1-9]\d*$)/.test(pageNum))) {
        document.getElementById("numError").innerText="Please enter a number";
    }
    else {
        switch (event.keyCode) {
            case 13:
                window.location="http://localhost:8080/admin/viewProducts?pageNum="+pageNum;
        }
    }
}

function prePage() {
    var pageNum = document.getElementsByName('pageNum')[0].value;
    if(pageNum == 1) {
        return false;
    }
    return true;
}

function nextPage() {
    var pageNum = document.getElementsByName('pageNum')[0].value;
    var total = document.getElementsByName('total')[0].innerText;
    if(pageNum == total) {
        return false;
    }
    return true;
}

function createXMLHttpRequest() {
    if ( window.XMLHttpRequest )  /*For all kinds of Browsers except for IE*/
    {
        xhr = new XMLHttpRequest();
    } else if ( window.ActiveObject )  /*For IE6 and above*/
    {
        xhr = new ActiveObject( "Msxml2.XMLHTTP" );
    } else /*For IE under version 6*/
    {
        xhr = new ActiveObject( "Microsoft.XMLHTTP" );
    }
}